import { request } from '@umijs/max';

interface UserInfo {
  id: number;
  username: string;
  email: string;
  avatar: string;
  createTime: string;
  updateTime: string;
  isActive: boolean;
}

interface LoginDataVO {
  token: string;
  userInfo: UserInfo;
}

// 登录
export const login = (data: any) => {
  return request<LoginDataVO>('/user/login', {
    method: 'POST',
    data,
  });
};

// 注册
export const register = (data: any) => {
  return request<void>('/user/register', {
    method: 'POST',
    data,
  });
};

// 获取用户信息
export const getUserInfo = () => {
  return request<UserInfo>('/user/info', {
    method: 'GET',
  });
};

